package com.pattern.strategy_youth.demo3;

import com.pattern.strategy_youth.demo2.OrderType;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ：qs
 * @date ：Created in 2022/3/3
 * @description： 策略的创建
 * 如果业务场景需要每次都创建不同的策略对象，我们就要用另外一种工厂类的实现方式
 * @modified By：
 */
public class DiscountStrategyFactory {

    private static final Map<OrderType, DiscountStrategy> strategies = new HashMap<>();

    static {
        strategies.put(OrderType.NORMAL, new NormalDiscountStrategy()); // 普通订单
        strategies.put(OrderType.NORMAL, new GrouponDiscountStrategy()); // 团购订单
        strategies.put(OrderType.NORMAL, new PromotionDiscountStrategy()); // 促销订单
    }

    public static DiscountStrategy getDiscountStrategy(OrderType type){
        return strategies.get(type);
    }
}
